package com.gk.company.view.bottom
{
	import com.gk.company.view.event.GoFriendCompanyEvent;
	import com.gk.company.view.event.GoMyCompanyEvent;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import org.robotlegs.mvcs.Mediator;
	
	public class SysBtnViewMediator extends Mediator
	{
		
		[Inject]
		public var sysBtnView:SysBtnView;
		
		public function SysBtnViewMediator()
		{
			super();
		}
		
		override public function onRegister():void
		{
			eventMap.mapListener(eventDispatcher,GoFriendCompanyEvent.GO_FRIEND_COMPANY,updateAllData,GoFriendCompanyEvent)
			eventMap.mapListener(eventDispatcher,GoMyCompanyEvent.GO_MY_COMPANY,updateAllData,GoMyCompanyEvent)
			
			eventMap.mapListener(sysBtnView.backBtn,MouseEvent.CLICK,backHandler,MouseEvent)
			
		}
		
		private function backHandler(e:MouseEvent):void
		{
			dispatch(new GoMyCompanyEvent(GoMyCompanyEvent.BACK_TO_MY_COMPANY));
			
		}
		
		private function updateAllData(e:Event):void
		{
			sysBtnView.isMyCompany((e is GoMyCompanyEvent));
		}
		
	}
}